<template>
	<view>
		<view class='cash-withdrawal'>

			<view class='wrapper'>
				<view class='list'>

					<view class='item  row-between-wrapper' style="border-bottom: 1rpx solid #FFFFFF;">
						<!-- <view class='name'>银行卡</view> -->
						<uni-collapse  ref="collapse"   @change="onChange()" >
							<uni-collapse-item :show-animation="true" name="1"  title="选择提现银行卡"  :open="isshow"  >
								<view class="box-s3" v-if="cardList.length != 0" style="padding: 20rpx;">
										<view class="cart" v-for="(item,index) in cardList" :key="index" @click="choosebank(item)">
											<bancart :bankCode="item.abbreviation" :url="item.bank_pic" :bankName="item.bank_name" :cardType="item.type"
												:cardCode="item.bank_code"></bancart>
										</view>
									</view>
							</uni-collapse-item>
						</uni-collapse>
						<bancart v-if="ischooes" :bankCode="activecart.abbreviation" :bankName="activecart.bank_name" :cardType="activecart.type"
							:cardCode="activecart.bank_code"></bancart>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'>提现</view>
						<view class='input'><input :placeholder='"最低提现金额"+minPrice' placeholder-class='placeholder'
								v-model="money" type='digit'></input></view>
					</view>
					<!-- 	<view class='item acea-row row-top row-between'>
							<view class='name'>收款码</view>
							<view class="input acea-row">
								<view class="picEwm" v-if="qrcodeUrlZ">
									<image :src="qrcodeUrlZ"></image>
									<text class='iconfont icon-guanbi1 font-color' @click='DelPicZ'></text>
								</view>
								<view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic("Z")' v-else>
								  <text class='iconfont icon-icon25201'></text>
								  <view>上传图片</view>
								</view>
							</view>
						</view> -->
					<view class='tip'>
						当前可提现金额: <text class="s-money">￥{{userInfo.now_money}}</text>
					</view>
					<view class='tip'>
						说明: 提现后等待后台转账到银行卡,24小时内未到账请联系客服!
					</view>
					<button @click="submit" class='bnt bg-color'>提现</button>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import bancart from '../../../components/bankcart/index.vue'
	import uniCollapse from '../../../components/uni-ui/lib/uni-collapse/uni-collapse.vue'
	import uniCollapseItem from '../../../components/uni-ui/lib/uni-collapse/components/uni-collapse-item/uni-collapse-item.vue'
	import {
		Withdrawal,
		userBankList,
		getBankType,userinfo,getMinWithdrawal
	} from '../../../api/api.js'
	export default {
		components: {
			bancart,
			uniCollapse,uniCollapseItem
		},
		data() {
			return {
				index: 0,
				bank_id: "",
				money: "",
				isshow:false,
				ischooes:false,
				cardList: [],
				minPrice: 0.00, //最低提现金额
				userInfo: {},
				activecart:{}
			};
		},
		onLoad() {
			this.datainit()
				this.userInfo = uni.getStorageSync('userInfo')
		},
		methods: {
			onChange(e){
				console.log(e)
			},
			// 获取自己的银行卡
			datainit() {
				userBankList().then(res => {
					this.cardList = res.data
				})
				userinfo().then(res=>{
					this.userInfo = res.data
					uni.setStorageSync('userInfo',this.userInfo)
				})
				getMinWithdrawal().then(res=>{
					this.minPrice = res.msg
				})
			},
			choosebank(e){
				console.log(e)
				this.activecart = e
				this.bank_id = e.id
				this.ischooes =true
				this.$refs.collapse.$children[0].isOpen = false
			},
			// 申请提现
			submit() {
				let data = {
					money: this.money,
					bank_id: this.bank_id
				}
				Withdrawal(data).then(res => {
					uni.showToast({
						title: res.msg,
						icon: "success"
					})
					if(res.status == 200){
						uni.navigateTo({
							url:"/pages/users/money/index"
						})
					}
				})
			},


		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #fff !important;
	}

	.cash-withdrawal .nav {
		height: 130rpx;
		box-shadow: 0 10rpx 10rpx #f8f8f8;
	}

	.cash-withdrawal .nav .item {
		font-size: 26rpx;
		flex: 1;
		text-align: center;
	}

	.cash-withdrawal .nav .item~.item {
		border-left: 1px solid #f0f0f0;
	}

	.cash-withdrawal .nav .item .iconfont {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;
		border: 2rpx solid #6DD375;
		text-align: center;
		line-height: 37rpx;
		margin: 0 auto 6rpx auto;
		font-size: 22rpx;
		box-sizing: border-box;
	}

	.cash-withdrawal .nav .item .iconfont.on {
		background-color: #6DD375;
		color: #fff;
		border-color: #6DD375;
	}

	.cash-withdrawal .nav .item .line {
		width: 2rpx;
		height: 20rpx;
		margin: 0 auto;
		transition: height 0.3s;
	}

	.cash-withdrawal .nav .item .line.on {
		height: 39rpx;
	}

	.cash-withdrawal .wrapper .list {
		padding: 0 30rpx;
	}

	.cash-withdrawal .wrapper .list .item {
		border-bottom: 1rpx solid #eee;
		min-height: 28rpx;
		font-size: 30rpx;
		color: #333;
		padding: 39rpx 0;
	}

	.cash-withdrawal .wrapper .list .item .name {
		width: 130rpx;
	}

	.cash-withdrawal .wrapper .list .item .input {
		width: 505rpx;
	}

	.cash-withdrawal .wrapper .list .item .input .placeholder {
		color: #bbb;
	}

	.cash-withdrawal .wrapper .list .item .picEwm,
	.cash-withdrawal .wrapper .list .item .pictrue {
		width: 140rpx;
		height: 140rpx;
		border-radius: 3rpx;
		position: relative;
		margin-right: 23rpx;
	}

	.cash-withdrawal .wrapper .list .item .picEwm image {
		width: 100%;
		height: 100%;
		border-radius: 3rpx;
	}

	.cash-withdrawal .wrapper .list .item .picEwm .icon-guanbi1 {
		position: absolute;
		right: -14rpx;
		top: -16rpx;
		font-size: 40rpx;
	}

	.cash-withdrawal .wrapper .list .item .pictrue {
		border: 1px solid rgba(221, 221, 221, 1);
		font-size: 22rpx;
		color: #BBBBBB;
	}

	.cash-withdrawal .wrapper .list .item .pictrue .icon-icon25201 {
		font-size: 47rpx;
		color: #DDDDDD;
		margin-bottom: 3px;
	}

	.cash-withdrawal .wrapper .list .tip {
		font-size: 26rpx;
		color: #999;
		margin-top: 25rpx;
	}

	.cash-withdrawal .wrapper .list .bnt {
		font-size: 32rpx;
		color: #fff;
		width: 690rpx;
		height: 90rpx;
		text-align: center;
		border-radius: 50rpx;
		line-height: 90rpx;
		margin: 64rpx auto;
	}

	.cash-withdrawal .wrapper .list .tip2 {
		font-size: 26rpx;
		color: #999;
		text-align: center;
		margin: 44rpx 0 20rpx 0;
	}

	.cash-withdrawal .wrapper .list .value {
		height: 135rpx;
		line-height: 135rpx;
		border-bottom: 1rpx solid #eee;
		width: 690rpx;
		margin: 0 auto;
	}

	.cash-withdrawal .wrapper .list .value input {
		font-size: 80rpx;
		color: #282828;
		height: 135rpx;
		text-align: center;
	}

	.cash-withdrawal .wrapper .list .value .placeholder2 {
		color: #bbb;
	}

	.price {
		color: #FD3833;
	}


	.phone {
		// position: absolute;
		height: 350rpx;
		background-color: #FFFFFF;
		width: 90%;
		margin-left: 50%;
		transform: translateX(-50%);
		// margin-top: -180rpx;
		margin-top: 30rpx;
		border-radius: 25rpx;
		/* width: 750upx; */
		box-sizing: border-box;

		.logo {
			position: absolute;
			border-radius: 50%;
			top: 40rpx;
			left: 40rpx;
		}

		.bank_name {
			font-size: 40rpx;
			font-weight: 500;
			color: #FFFFFF;
			position: absolute;
			top: 40rpx;
			left: 175rpx;
		}

		.type {
			font-size: 23rpx;
			color: #FFFFFF;
			position: absolute;
			top: 110rpx;
			left: 175rpx;
		}

		.number {
			font-size: 42rpx;
			color: #FFFFFF;
			position: absolute;
			bottom: 44rpx;
			right: 110rpx;
		}
	}
</style>
